<template>
    <div style="width: 100%;height: 100%;margin: 0 auto;margin-top: auto;">
        <div>登录中...请勿刷新页面</div>
    </div>
</template>

<script setup>
import { ref, reactive, getCurrentInstance, nextTick } from "vue";
import { useRoute, useRouter } from "vue-router";
import VueCookies from 'vue-cookies';

const { proxy } = getCurrentInstance();
const router = useRouter();
const route = useRoute();
const api = {
    logincallback: "/qqlogin/callback",
};

const login = async () => {
    let result = await proxy.Request({
        url: api.logincallback,
        params: router.currentRoute.value.query,
        errorCallback: () => {
            router.push("/");
        },
    });
    if (!result) {
        return;
    }
    let redirectUrl = result.data.errorCallback || "/";
    if (redirectUrl == "/login") {
        redirectUrl = "/";
    }
    proxy.VueCookies.set("userInfo", result.data.userInfo, 0);
    router.push(redirectUrl);
};

login();

</script>

<style lang="scss" scoped></style>
